#!/bin/sh

HTTPD_ROOTDIR='/var/www'

cp /usr/local/lib/mailgraph/mailgraph.cgi ${HTTPD_ROOTDIR}/cgi-bin/

echo "Enable mailgraph..."

echo "mailgraph_flags='-l /var/log/maillog --daemon-rrd=/var/www/cgi-bin/ -d'" >> /etc/rc.conf.local

cat >> /etc/rc.local <<EOF
# Start mailgraph.
if [ X"\${mailgraph_flags}" != X"NO" ]; then
    echo -n ' mailgraph'
    /usr/local/bin/mailgraph \${mailgraph_flags}
fi
EOF

echo "Done."
